<?php
session_start();
ob_start();
include_once 'include/common.php';
$core = new core();
if (!$core->CheckLogin()) {
    header('Location:login.php');
}
$list_category = $core->getListCategory();
$list_category_parent = $core->getCategoryByParentId(0);

?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Zen store</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
        <meta name="author" content="Muhammad Usman">

        <!-- The styles -->
        <link id="bs-css" href="css/bootstrap-cerulean.css" rel="stylesheet">
        <style type="text/css">
            body {
                padding-bottom: 40px;
            }
            .sidebar-nav {
                padding: 9px 0;
            }
        </style>
        <link href="css/bootstrap-responsive.css" rel="stylesheet">
        <link href="css/charisma-app.css" rel="stylesheet">
        <link href="css/style.css" rel="stylesheet">
        <link href="css/jquery-ui-1.8.21.custom.css" rel="stylesheet">

        <link href='css/chosen.css' rel='stylesheet'>
        <link href='css/uniform.default.css' rel='stylesheet'>

        <link href='css/jquery.cleditor.css' rel='stylesheet'>


        <link href='css/jquery.iphone.toggle.css' rel='stylesheet'>

        <link href='css/uploadify.css' rel='stylesheet'>

        <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
          <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

        <!-- The fav icon -->
        <link rel="shortcut icon" href="img/favicon.ico">

    </head>

    <body>
        <div id="page-wrap" class="page-wrap body-wrap ">
            <div id="page-tray" class="tray transition">
                <?php include_once ('new_menu.php'); ?>

                <div id="page-content" class="page-content transition profile-page">
                    <?php include_once ('navbar.php'); ?>
                    <div class="container-fluid">
                        <div class="row-fluid">
                            <div id="content" class="span12"> 
                                <!--                                <div>
                                                                    <ul class="breadcrumb">
                                                                        <li>
                                                                            <a href="#">Home</a> <span class="divider">/</span>
                                                                        </li>
                                                                        <li>
                                                                            <a href="#">Forms</a>
                                                                        </li>
                                                                    </ul>
                                                                </div>-->
                                <div class="row-fluid sortable">		
                                    <div class="box span12">
                                        <div class="box-header well" data-original-title>
                                            <h2><i class="icon-user"></i>Danh sách Category</h2>

                                        </div>
                                        <div class="box-content" id="box_content_customer_order" style="height: 400px;">

                                            <input type="hidden" name="category_id" id="category_id" value="0">
                                            <table class="table table-striped table-bordered bootstrap-datatable datatable" id="table_customer_order">
                                                <thead>
                                                    <tr>
                                                        <th>Tên category</th>
                                                        <th>Parent category</th>

                                                        <th>Actions</th>
                                                    </tr>
                                                </thead>   
                                                <tbody id="tbody_category_list">
                                                    <?php
                                                    if ($list_category) {
                                                        foreach ($list_category as $category) {
                                                            ?>
                                                            <tr>
                                                                <td class="center" ><?php echo $category->category_name; ?></td>
                                                                <td class="center"><?php echo $category->category_parent; ?></td>

                                                                <td class="center" >
                                                                    <?php
                                                                    if ($_SESSION["user_role"] != 3) {
                                                                        ?>
                                                                        <a class="btn btn-info btn_edit_category" href="javascript:void(0)" rel="<?php echo $category->category_id; ?>">
                                                                            <i class="icon-edit icon-white"></i>  
                                                                            Edit                                            
                                                                        </a>
                                                                        <a href="#" class="btn btn-danger btn_delete_category" rel="<?php echo $category->category_id; ?>">
                                                                            <i class="icon-trash icon-white"></i> 
                                                                            Delete
                                                                        </a>
                                                                        <?php
                                                                    }
                                                                    ?>
                                                                </td>
                                                            </tr>
                                                            <?php
                                                        }
                                                    }
                                                    ?>
                                                </tbody>
                                            </table>
                                            <div id="loading" style="display:none;width: 220px; height: 19px;margin: 0 auto;"><img title="img/ajax-loaders/ajax-loader-7.gif" src="img/ajax-loaders/ajax-loader-7.gif"></div>
                                        </div>
                                    </div><!--/span-->

                                </div><!--/row-->
                                <?php
                                if ($_SESSION["user_role"] != 3) {
                                    ?>
                                    <div class="row-fluid sortable">
                                        <div class="box span12">
                                            <div class="box-header well" data-original-title>
                                                <h2><i class="icon-edit"></i> Thêm Category</h2>

                                            </div>
                                            <div class="box-content">
                                                <form class="form-horizontal">
                                                    <fieldset>
                                                        <div class="control-group">
                                                            <label class="control-label" ></label>
                                                            <div class="controls">
                                                                <div class="alert alert-error" id="alert-error-category" style="display:none">
                                                                </div>
                                                                <div class="alert alert-success" id="alert-success-category" style="display:none"></div>
                                                            </div>
                                                        </div>

                                                        <div class="control-group">
                                                            <label class="control-label" for="product_name">Tên category </label>
                                                            <div class="controls">
                                                                <input type="text" class="span6 typeahead" id="category_name"  >

                                                            </div>
                                                        </div>




                                                        <div class="control-group">
                                                            <label class="control-label" for="selectError3">Parent category</label>
                                                            <input type="hidden" name="parent_category_id" id="parent_category_id">
                                                            <div class="controls" id="category_parent">

                                                                <select class ="category_parent">
                                                                    <option value="0">Chọn category</option>
                                                                    <?php
                                                                    if ($list_category_parent) {
                                                                        foreach ($list_category_parent as $category) {
                                                                            ?>
                                                                            <option value="<?php echo $category->category_id; ?>"><?php echo $category->category_name; ?></option>

                                                                            <?php
                                                                        }
                                                                    }
                                                                    ?>
                                                                </select>

                                                            </div>
                                                        </div>



                                                        <div class="form-actions">
                                                            <button type="button" class="btn btn-primary" id="save_category">Save changes</button>
                                                            <button type="reset" class="btn">Cancel</button>
                                                        </div>
                                                    </fieldset>
                                                </form>   

                                            </div>
                                        </div><!--/span-->

                                    </div><!--/row-->
                                    <?php
                                }
                                ?>
                            </div><!--/#content.span10-->

                        </div><!--/fluid-row-->
                        <?php include_once ('footer.php'); ?>

                    </div><!--/.fluid-container-->
                </div>
            </div>
        </div>

        <!-- external javascript
        ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->

        <!-- jQuery -->
        <script src="js/jquery-1.7.2.min.js"></script>
        <!-- jQuery UI -->
        <script src="js/jquery-ui-1.8.21.custom.min.js"></script>
        <!-- transition / effect library -->
        <script src="js/bootstrap-transition.js"></script>
        <!-- alert enhancer library -->
        <script src="js/bootstrap-alert.js"></script>

        <!-- library for creating tabs -->
        <script src="js/bootstrap-tab.js"></script>
        <!-- library for advanced tooltip -->
        <script src="js/bootstrap-tooltip.js"></script>
        <!-- popover effect library -->
        <script src="js/bootstrap-popover.js"></script>

        <script src="js/bootstrap-collapse.js"></script>

        <script src="js/jquery.cookie.js"></script>


        <!-- select or dropdown enhancer -->
        <script src="js/jquery.chosen.min.js"></script>
        <!-- checkbox, radio, and file input styler -->
        <script src="js/jquery.uniform.min.js"></script>

        <script src="js/jquery.cleditor.min.js"></script>

        <script src="js/jquery.iphone.toggle.js"></script>
        <!-- autogrowing textarea plugin -->
        <script src="js/jquery.autogrow-textarea.js"></script>
        <!-- multiple file upload plugin -->
        <script src="js/jquery.uploadify-3.1.min.js"></script>
        <!-- history.js for cross-browser state change on ajax -->
        <script src="js/jquery.history.js"></script>
        <!-- application script for Charisma demo -->
        <script src="js/common.js?t=1"></script>
        <script src="js/addCategory.js?t=1"></script>



    </body>
</html>

